package com.rpframework.website.device.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.rpframework.core.BaseService;
import com.rpframework.utils.NumberUtils;
import com.rpframework.utils.Pager;
import com.rpframework.website.device.dao.IPayMentDao;
import com.rpframework.website.device.domain.PayMent;

@Service
public class PayMentService extends BaseService{
	public @Resource IPayMentDao iDao;
	
	public Pager<PayMent> getPager(Pager<PayMent> pager) {
		long startTime = System.currentTimeMillis();
		List<PayMent> list = iDao.doPager(this.packageMyBatisParam(pager));
		pager.setItemList(list);
		pager.setCostTime(System.currentTimeMillis() - startTime);
		return pager;
	}
	
	public boolean doSaveOrUpdate(PayMent t) {
		if(StringUtils.isNotBlank(t.getId())){
			t.setModifyTime(System.currentTimeMillis()/1000);
			return iDao.update(t);
		}else{
			t.setCreateTime(System.currentTimeMillis()/1000);
			t.setState(1);
			return iDao.insert(t);
		}
	}

	public JsonElement getJsonInfo() {
		JsonObject json = new JsonObject();
		json.addProperty("room", "缴费房间");
		json.addProperty("id", "paymentId");
		json.addProperty("startTime", "起始时间");
		json.addProperty("endTime","截止时间" );
		json.addProperty("price", "应缴金额");
		json.addProperty("usePoint", "可用积分");
		json.addProperty("deductPoint", "积分已扣除");
		json.addProperty("deductMoney", "积分已抵扣金额");
		json.addProperty("realMoney", "实缴金额");
		json.addProperty("balance", "余额");
		return json;
	}

}
